from typing import *


class Solution:

    def maximizeGreatness(self, nums: List[int]) -> int:
        nums.sort()
        l = 0
        ans = 0
        for r in range(1, len(nums)):
            if nums[r] > nums[l]:
                ans += 1
                l += 1
        return ans